package com.wanye.utils;

import com.wanye.entity.Result;
import com.wanye.enums.ResultEnum;

/**
 * Created by wanye on 2017/9/24.
 */
public class ResultUtil {

    public static Result success() {
        return success(null);
    }

    public static Result success(Object data) {
        Result res = new Result();
        res.setCode(ResultEnum.SUCCESS.getCode());
        res.setMsg(ResultEnum.SUCCESS.getMsg());
        res.setData(data);
        return res;
    }

    public static Result error(ResultEnum resultEnum) {
        return error(resultEnum,resultEnum.getMsg());
    }

    public static Result error(ResultEnum resultEnum, String msg) {
        Result res = new Result();
        res.setCode(resultEnum.getCode());
        res.setMsg(msg);
        return res;
    }
}
